package com.wsx.sky.dubbo.controller;

import com.wsx.sky.dubbo.bean.DubboRequest;
import com.wsx.sky.dubbo.bean.DubboResponse;
import com.wsx.sky.dubbo.service.DubboClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @author wangshuaixin
 * @Title: com.wsx.sky.dubbo.controller.DubboServerController
 * @Description: TODO
 * @date 2018/12/11
 */
@RestController
@RequestMapping("/dubbo/client")
public class DubboServerController {

    @Autowired
    private DubboClientService dubboClientService;

    @RequestMapping(
            value = "/dubbo/{name}",
            method = {RequestMethod.GET}
    )
    public DubboResponse http(@PathVariable("name") String name) {
        DubboRequest request = new DubboRequest();
        request.setName(name);
        request.setDate(new Date());
        return dubboClientService.dubbo(request);
    }
}
